package ru.amse.baltijsky.javascheme.tree;

import ru.amse.baltijsky.javascheme.nodeshape.ActionNodeShape;
import ru.amse.baltijsky.javascheme.nodeshape.INodeShape;

/**
 * Represents a situation when the program flow continues outside the current block.
 * <code>break</code>s with labels are not considered in this implementation.
 *
 * @todo consider labeled breaks, think how it may change the logic of the program.
 */
public class BreakNode extends FlowChangeNode {
    /**
     * Default constructor. Creates a node without previous or parent (nesting) node.
     */
    public BreakNode() {
        super();
    }

    public BreakNode(SchemaNode parentNode, SchemaNode prevNode) {
        super(parentNode, prevNode);
    }

    /**
     * Constructs a new node without previous or nesting node and with information about the corresponding code.
     *
     * @param s code associated with the node
     */
    public BreakNode(String[] s) {
        super(s);
    }

    /**
     * Constructs a new node with full information about the nesting and previous nodes and the corresponding code.
     *
     * @param parentNode link to the parent (nesting) node
     * @param prevNode   link to the node that is previous in the sense of program flow
     * @param s          code associated with the node
     */
    public BreakNode(SchemaNode parentNode, SchemaNode prevNode, String[] s) {
        super(parentNode, prevNode, s);
    }

    public INodeShape getShape() {
        return new ActionNodeShape(getCodeAsString());
    }

    public NodeType getNodeType() {
        return NodeType.BREAK;
    }
}
